package masterMind;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

public class Solution {
    public int[] masterMind(String solution, String guess) {
        // 猜中的次数

        // 为猜中 不是猜中的并且 字符串slolution中包含该字符
        int[] ans = new int[2];
        LinkedList<Integer> list = new LinkedList<>();
        LinkedList<Character> list1 = new LinkedList<>();
        for (int i = 0; i < solution.length(); i++) {
            if(solution.charAt(i) == guess.charAt(i)) {
                ans[0]++; // 猜中的次数
            } else {
                list1.add(solution.charAt(i));
                list.add(i);
            }
        }
        //
        System.out.println(list1);
        System.out.println(list);
        for (int i = 0; i < list.size(); i++) {
            Character c = guess.charAt(list.get(i));
            if(list1.contains(c) ){
                ans[1]++;
                list1.remove(c);
            }
        }
        return ans;
    }
}
